package dse;

import java.util.Iterator;
import java.util.Vector;
import java.io.Serializable;

/**
 * Stores a ranking of data objects to be used when generating requests.
 * 
 * Note: 1 is the highest ranking.
 * 
 * @author Sam
 *
 */
public class DataObjectAccessRanking implements Iterable<DataObject>, Serializable 
{
	private static final long serialVersionUID = 1L;
	Vector<DataObject> rankings;
	
	public DataObjectAccessRanking (int size) {
		rankings = new Vector<DataObject>(size);
		for (int a = 0; a < size; a++)
			rankings.add(null);
	}
	
	public DataObject get (int rank) {
		return rankings.get(rank-1);
	}
	public void set (int rank, DataObject value) {
		rankings.set(rank-1,value);
	}
	
	public Iterator<DataObject> iterator () {
		return rankings.iterator();
	}
	
	public DataObjectAccessRanking clone () 
	{
		DataObjectAccessRanking other = 
			new DataObjectAccessRanking (rankings.size());
		
		for (int a = 0; a < rankings.size(); a++)
			other.set(a+1, rankings.get(a));
		
		return other;
	}
}
